<template>
	<view class="content">
		<view class="head">
			<view class="back" @click="backPage"><u-icon name="arrow-left"  size="22" :bold="true"></u-icon></view>
			<view class="title-top">{{title}}</view>
		</view>
		<view class="today-income-content">
		  <view class="total">
		    <view class="num">
		      <text>总额</text>
		      <text class="value">{{ data.totalPrice || "0.00" }}</text>
		    </view>
		  </view>
		  <view class="text-area">
		    <text class="title">共{{ data.totalCount || "0" }}笔</text>
		    <u-cell-group>
		      <u-cell v-for="(item, index) in data.items" :key="index">
		        <view slot="title" class="u-slot-title1">
		          <text class="u-cell-text">{{
		            item.orderNumberString || item.orderNumber || "--"
		          }}</text>
		          <text class="tips1">{{ item.payTime || "--" }}</text>
		        </view>
		        <view slot="value" class="u-slot-title2">
		          <text class="tips2">{{ item.realPrice || "--" }}</text>
		          <text class="u-cell-text">{{ item.payType || "--" }}</text>
		        </view>
		      </u-cell>
		    </u-cell-group>
		  </view>
		</view>
	</view>

</template>

<script>
import { getStoreData, setStoreData, httpPost, httpGet } from "@/utils/http.js";
const date = new Date();
const year = date.getFullYear();
const month =
  date.getMonth() + 1 > 9 ? date.getMonth() + 1 : "0" + (date.getMonth() + 1);
const date1 = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
const dateTwo = new Date(year, date.getMonth()+1, 0);
const lastDay=dateTwo.getDate();
export default {
  data() {
    return {
      data: {},
	  title:"今日收款"
    };
  },
  onLoad(option) {
	  if(option.type){
		  if(option.type=='day'){
			  this.title="今日收款";
			  this.getdataFun();
		  }
		  if(option.type=='month'){
			this.title="当月收款";
		  	this.getMonthFun();
		  }
	  }else{
		  this.title="今日收款";
		  this.getdataFun(); 
	  }
	  console.log(this.title)
    
  },
  methods: {
    getdataFun() {
      const _this = this;
      httpPost("/api/sellerstore/queryBill", {
        startTime: year + "-" + month + "-" + date1 + " 00:00:00",
        endTime: year + "-" + month + "-" + date1 + " 23:59:59",
        // payType: null, //1普通，2分账
      })
        .then((res) => {
          _this.data = res.data;
        })
        .catch((e) => {
          //
        });
    },
	getMonthFun(){
		const _this = this;
		httpPost("/api/sellerstore/queryBill", {
		  startTime: year + "-" + month  + "-01 00:00:00",
		  endTime: year + "-" + month + "-" + lastDay + " 23:59:59",
		  // payType: null, //1普通，2分账
		})
		  .then((res) => {
		    _this.data = res.data;
		  })
		  .catch((e) => {
		    //
		  });
	},
	backPage(){
		uni.navigateBack();
	}
  },
};
</script>

<style lang="scss">
.today-income-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  .text-area {
    width: 100vw;
    color: #333;
    font-size: 14px;
    margin-top: 64px;
    .tips1 {
      color: #666;
      margin-top: 6px;
    }
    .tips2 {
      color: #f00;
      text-align: right;
      margin-bottom: 6px;
    }
    .title {
      line-height: 30px;
      color: #666;
      margin-left: 16px;
    }
  }
  .u-slot-title1 {
    display: flex;
    flex-direction: column;
  }
  .u-slot-title2 {
    display: flex;
    flex-direction: column;
  }
  .total {
    width: 120px;
    height: 120px;
    display: flex;
    margin-top: 32px;
    font-size: 14px;
    color: #fff;
    justify-content: center;
    align-content: center;
    background: linear-gradient(-90deg, #f90, #f60);
    box-shadow: 2px 2px 22px 1px rgba(247, 213, 62, 0.897);
    border-radius: 50%;
    .num {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      .value {
        font-size: 16px;
        line-height: 30px;
      }
    }
  }
}
.content{
	padding-top: 80rpx;
}
.head{
	display: flex;
	flex-direction: row;
	justify-content: flex-start;
	.title-top{
		font-size: 30rpx;
		text-align: center;
		width: 590rpx;
		line-height: 80rpx;
	}
	.back{
		width: 80rpx;
		display: flex;
		justify-content: center;
	}
}
</style>
